/*
 * Copyright 2012-2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.webapp.annotation.bean;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Annotation configured address bean.
 * 
 * @author Edwin Xico
 */
@Entity
@Table(name="BOOK")
public class Book {
    
    
    private Integer id = null;
    private String book = null;
    private String autor = null;
    private String editorial = null;
    private String isbn = null;
    private Date created = null;

    /**
     * Gets id (primary key)
     * @return 
     */
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    public Integer getId() {
        return id;
    }

    /**
     * Sets id (primary key).
     * @param id 
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * Gets title.
     * @return 
     */
    public String getBook() {
        return book;
    }

    /**
     * Sets title.
     * @param title 
     */
    public void setBook(String book) {
        this.book = book;
    }

    /**
     * Gets Autor.
     * @return 
     */
    public String getAutor() {
        return autor;
    }

    /**
     * Sets Autor.
     * @param aoutor 
     */
    public void setAutor(String aoutor) {
        this.autor = aoutor;
    }

    /**
     * Gets Editorial.
     * @return 
     */
    public String getEditorial() {
        return editorial;
    }

    /**
     * Sets Editorial.
     * @param editorial 
     */
    public void setEditorial(String editorial) {
        this.editorial = editorial;
    }

    /**
     * Gets Editorial.
     * @return 
     */ 
    @Column(name="ISBN")
    public String getIsbn() {
        return isbn;
    }

    /**
     * Sets isbn.
     * @param isbn 
     */
    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }

    /**
     * Gets created.
     * @return 
     */
    public Date getCreated() {
        return created;
    }

    /**
     * Sets created.
     * @param created 
     */
    public void setCreated(Date created) {
        this.created = created;
    }
    
    /**
     * Returns a string representation of the object.
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        
        sb.append(this.getClass().getName() + "-");
        sb.append("  id=" + id);
        sb.append("  book=" + book );
        sb.append("  autor=" + autor);
        sb.append("  aditorial=" + editorial);
        sb.append("  isbn=" + isbn);
        sb.append("  created=" + created);
        
        return sb.toString();
    }
    
    /**
     * Returns a hash code value for the object.
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((book == null) ? 0 : book.hashCode());
        result = prime * result + ((autor == null) ? 0 : autor.hashCode());
        result = prime * result + ((created == null) ? 0 : created.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((editorial == null) ? 0 : editorial.hashCode());
        result = prime * result
                + ((isbn == null) ? 0 : isbn.hashCode());
        
        return result;
    }
    
    /**
     * Iicates whether some object is equal to this one.
     */
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return  false;
        if (getClass() != obj.getClass())
            return false;
        final Book other = (Book) obj;
        if (book == null) {
            if(other.book != null)
                return false;
        } else if (!book.equals(other.book))
            return false;
        if (autor == null) {
            if (other.autor != null)
                return false;
        } else if (!autor.equals(other.autor))
            return false;
        if (created == null) {
            if(other.created != null)
                return false;
        } else if (!created.equals(other.created))
            return false;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        if (editorial == null) {
            if (other.editorial != null)
                return false;
        } else if (!editorial.equals(other.editorial))
            return false;
        if (isbn == null) {
            if (other.isbn != null)
                return false;
        } else if (!isbn.equals(other.isbn))
            return false;
        return true;
    }

}